/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cfs.databean;

import java.sql.Date;

/**
 *
 * @author danny seow
 */
public class Datapoint {
    private int year;
    private int month;
    private int date;
    private double price;

    public Datapoint(FundPriceHistory fph){
        long fphPrice = fph.getPrice();
        double afterDivision = fphPrice * 0.01;
        this.price = afterDivision;
        String valueDate = fph.formatDate(fph.getPrice_date());
        String year1 = valueDate.substring(0, 4);
        String month1 = valueDate.substring(5,7);
        String day1 = valueDate.substring(8,10);
        setDate(day1);
        setMonth(month1);
        setYear(year1);
    }
    public int getDate() {
        return date;
    }

    private void setDate(String dayS) {
        this.date = Integer.parseInt(dayS);
    }

    public int getMonth() {
        return month;
    }

    private void setMonth(String monthS) {
        int monthInt = Integer.parseInt(monthS);
        switch(monthInt){
            case 1: this.month = 0;
                    break; 
            case 2: this.month = 1;
                    break; 
            case 3: this.month = 2;
                    break; 
            case 4: this.month = 3;
                    break; 
            case 5: this.month = 4;
                    break; 
            case 6: this.month = 5;
                    break; 
            case 7: this.month = 6;
                    break; 
            case 8: this.month = 7;
                    break; 
            case 9: this.month = 8;
                    break; 
            case 10: this.month = 9;
                     break; 
            case 11: this.month = 10;
                     break; 
            case 12: this.month = 11;
                     break; 
        }
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getYear() {
        return year;
    }

    private void setYear(String yearS) {
        this.year = Integer.parseInt(yearS);
    }
}
